var sdk = {};
// sdk.baseIP = 'http://33k931m051.wicp.vip/';
// sdk.companyIp = 'http://33k931m051.wicp.vip/';
//113.238.142.107/jinzhou-servicePlatfotm
// sdk.baseIP = "https://ggzy.jz.gov.cn:8606/";
// sdk.companyIp = "https://ggzy.jz.gov.cn:8606/";
sdk.baseIP = "https://ggzy.jz.gov.cn:8606/";
sdk.companyIp = "https://ggzy.jz.gov.cn:8606/";
// 获取URL中的参数
sdk.getURLVar = function (name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  var r = window.location.search.substr(1).match(reg);
  return r != null ? decodeURI(r[2]) : null;
};
sdk.setURLVar = function (url, key, value) {
  if (url) {
    var urlList = url.split("#");
    var params = {};
    var query = urlList[0].split("?")[1];
    var result = urlList[0].split("?")[0] + "?";
    if (query) {
      query = query.split("&");
      for (var i in query) {
        var vars = query[i].split("=");
        params[vars[0]] = vars[1];
      }
    }
    if (value) {
      params[key] = value;
    } else {
      params[key] = null;
      delete params[key];
    }
    var first = true;
    for (var i in params) {
      result += (first ? "" : "&") + i + "=" + (params[i] ? params[i] : "");
      first = false;
    }
    return result + (urlList[1] ? "#" + urlList[1] : "");
  }
  return "";
};

// 获取机构列表
sdk.getJgData = function (data) {
  $.ajax({
    type: "post",
    data: data,
    url: sdk.baseIP + "/mh/app/v2/jrjg/getNewJrjgPage",
    dataType: "json",
    success: function (data) {
      var total = data.total;
      var Arr = data.rows;
      var p = {};
      for (var i = 1; i <= parseInt(total / 15 + 1); i++) {
        p["s" + i] = sdk.setPageNation(15, i, Arr);
        $("#ckvpbe" + i).html($.templates("#ckvpbeTmpl").render(p["s" + i]));
      }
    },
  });
};
//数组分页效果
sdk.setPageNation = function pagination(pageSize, currentPage, arr) {
  var skipNum = (currentPage - 1) * pageSize; //跳过的数量
  var newArr =
    skipNum + pageSize >= arr.length
      ? arr.slice(skipNum, arr.length)
      : arr.slice(skipNum, skipNum + pageSize);
  return newArr;
};

// 获取当前浏览器
sdk.myBrowser = function myBrowser() {
  var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
  var isIE =
    userAgent.indexOf("compatible") > -1 &&
    userAgent.indexOf("MSIE") > -1 &&
    !isOpera; //判断是否IE浏览器
  var isIE11 =
    userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1; //判断是否IE浏览器
  var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
  var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
  var isSafari =
    userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
  var isChrome =
    userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
  if (isIE) {
    console.log("IE");
    return isIE;
  } else if (isOpera) {
    console.log("Opera");
    return !isOpera;
  } else if (isEdge) {
    console.log("Edge");
    return !isEdge;
  } else if (isFF) {
    console.log("FF");
    return !isFF;
  } else if (isSafari) {
    console.log("Safari");
    return !isSafari;
  } else if (isChrome) {
    console.log("Chrome");
    return !isChrome;
  } else if (isIE11) {
    console.log("IE11");
    return isIE11;
  }
};

// 监听登录选择
sdk.user = {
  4: {
    name: "企业用户",
    register: true,
    path: "zxw/company/xq/release_demand",
    yjfk: "zxw/company/ts/complaint_admin",
  },
  5: {
    name: "个人用户",
    register: true,
  },
  1: {
    name: "银行用户",
    register: false,
    path: "zxw/jrjg/bankDbsx/wdxq",
    yjfk: "zxw/jrjg/bankDbsx/tsgl",
    cpdel: "mh/app/product/proInfo",
    clName: "#bankJgDel",
  },
  3: {
    name: "政府部门",
    path: "zxw/gov/app/rzxq_rzytfx?tname=rzytfx",
    yjfk: "zxw/gov/app/tscl?tname=tscl",
    register: false,
  },
  6: {
    name: "保险用户",
    register: false,
    path: "zxw/bxjg/wdsp",
    cpdel: "mh/app/v2/pro/getBxjgProductInfoOne",
    clName: "#bxJgDel",
  },
  8: {
    name: "证券用户",
    register: false,
    path: "zxw/zqjg/wdsp",
    cpdel: "mh/app/v2/pro/getZqProductInfoViewOne",
    clName: "#zqJgDel",
  },
  2: {
    name: "担保公司",
    register: false,
    path: "zxw/jrjg/dbgsDbsx/auditList",
    cpdel: "mh/app/v2/pro/getDbjgProductInfoOne",
    clName: "#dbJgDel",
  },
  9: {
    name: "投资机构",
    register: false,
  },
  7: {
    name: "金融专员",
    path: "zxw/jrzy/index/finance_jrzy",
    register: false,
  },
};
